{% extends 'base.html.twig' %}
{% block body_bar %}
    <h5>{{ dry_translation('permissionAsign') }}</h5>
    <div class="ibox-tools">
        <a class="btn btn-outline btn-info" href="{{ path("group_index") }}" data-route="group_index">{{ dry_translation('list') }}</a>
    </div>
{% endblock %}
{% block body %}
    <form method="post" class="form-horizontal" id="permissionForm">
        <div class="form-horizontal">
            <div class="form-group">
                <label class="control-label col-sm-2">{{ dry_translation('Group.name') }}</label>
                <div class="col-sm-10"><input type="text" class="form-control" value="{{ group.name }}" disabled/></div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">{{ dry_translation('permissionAsign') }}</label>
                <div class="col-sm-10">
                    <table class="table">
                        <tr>
                            <td align="center">{{ dry_translation('name') }}</td>
                            <td align="center">{{ dry_translation('selectAll') }}|{{ dry_translation('selectTheInverse') }}</td>
                            <td align="center">{{ dry_translation('list') }}</td>
                            <td align="center">{{ dry_translation('show') }}</td>
                            <td align="center">{{ dry_translation('new') }}</td>
                            <td align="center">{{ dry_translation('edit') }}</td>
                            <td align="center">{{ dry_translation('delete') }}</td>
                        </tr>
                        <tr>
                            <td align="center"></td>
                            <td align="center"></td>
                            <td align="center">
                                <div class="btn-group">
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'index', 1)">{{ dry_translation('selectAll') }}</button>
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'index', 0)">{{ dry_translation('selectTheInverse') }}</button>
                                </div>
                            </td>
                            <td align="center">
                                <div class="btn-group">
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'show', 1)">{{ dry_translation('selectAll') }}</button>
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'show', 0)">{{ dry_translation('selectTheInverse') }}</button>
                                </div>
                            </td>
                            <td align="center">
                                <div class="btn-group">
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'new', 1)">{{ dry_translation('selectAll') }}</button>
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'new', 0)">{{ dry_translation('selectTheInverse') }}</button>
                                </div>
                            </td>
                            <td align="center">
                                <div class="btn-group">
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'edit', 1)">{{ dry_translation('selectAll') }}</button>
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'edit', 0)">{{ dry_translation('selectTheInverse') }}</button>
                                </div>
                            </td>
                            <td align="center">
                                <div class="btn-group">
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'delete', 1)">{{ dry_translation('selectAll') }}</button>
                                    <button class="btn btn-white" type="button" onclick="checkPermission('vGroup', 'delete', 0)">{{ dry_translation('selectTheInverse') }}</button>
                                </div>
                            </td>
                        </tr>
                        {% for k,v in permission %}
                            <tr>
                                <td align="center">{{ dry_translation(v.0.language) }}</td>
                                <td align="center">
                                    <div class="btn-group">
                                        <button class="btn btn-white" type="button" onclick="checkPermission('hGroup', '{{k}}', 1)">{{ dry_translation('selectAll') }}</button>
                                        <button class="btn btn-white" type="button" onclick="checkPermission('hGroup', '{{k}}', 0)">{{ dry_translation('selectTheInverse') }}</button>
                                    </div>
                                </td>
                                {% for kk,vv in v %}
                                    <td align="center"><label class="checkbox-inline i-checks"><input type="checkbox" name="permission[]" value="{{ vv.route }}" hGroup="{{ k }}" vGroup="{{ vv.group }}"{% if vv.route in hasPermission %} checked{% endif %}></label></td>
                                {% endfor %}
                            </tr>
                        {% endfor %}
                    </table>
                    <div class="hr-line-dashed"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">{{ dry_translation('permissionAsign') }}</label>
                <div class="col-sm-10">
                    {% for k,v in elsePermission %}
                        <div class="i-checks"><label><input type="checkbox" name="permission[]" value="{{ v.route }}"{% if v.route in hasPermission %} checked{% endif %}><i></i>&nbsp;&nbsp;{{ dry_translation(v.language) }}</label></div>
                    {% endfor %}
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2"></label>
                <div class="col-sm-10"><button type="button" class="btn btn-primary" onclick="submitPermissionForm()">{{ dry_translation('submit') }}</button></div>
            </div>
        </div>
    </form>
{% endblock %}
